package com.wxt.ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wxt.ssm.bean.Employee;
import com.wxt.ssm.bean.EmployeeExample;
import com.wxt.ssm.bean.EmployeeExample.Criteria;
import com.wxt.ssm.dao.EmployeeMapper;
@Service
public class EmployeeService {
	
	@Autowired
	private EmployeeMapper employeeMapper;
	 public List <Employee> getAll(){
		return employeeMapper.selectByExampleWithDept(null);
		 
	 }
	public void saveEmp(Employee employee) {
		// TODO Auto-generated method stub
		employeeMapper.insertSelective(employee);
			 
	}
	
	
	
	public boolean chenkuser(String empName) {
		EmployeeExample example=new EmployeeExample();
		Criteria cri=example.createCriteria();
		cri.andEmpNameEqualTo(empName);
		int exam =(int) employeeMapper.countByExample(example);
		System.out.print(exam);
		// TODO Auto-generated method stub
		return exam==0;
	}
	public Employee getEmp(Integer Id) {
		Employee emp=	employeeMapper.selectByPrimaryKey(Id);
		return emp;
	}
	public void updataEmp(Employee employee) {
		// TODO Auto-generated method stub
	
		employeeMapper.updateByPrimaryKeySelective(employee);
		
		
	}
	public void delempbyid(Integer id) {
		// TODO Auto-generated method stub
		employeeMapper.deleteByPrimaryKey(id);
	}
	public void delempbylist(List<Integer> list) {
		// TODO Auto-generated method stub
		EmployeeExample example=new EmployeeExample();
		Criteria cri=example.createCriteria();
		cri.andEmpIdIn(list);
		employeeMapper.deleteByExample(example);
	}
	

}
